﻿using System;
using System.Collections.Generic;

using MVCBootstrap.Web.Security;

using MongoDB.Bson.Serialization.Attributes;
//using MVCBootstrap.MongoDB.Web.Profile;

namespace MVCBootstrap.MongoDB {

	internal sealed class User : IUser {

		public User() {
			this.Roles = new List<String>();
		}

		[BsonId]
		public Guid Id { get; set; }
		[BsonElement(UserFieldNames.CreationDate)]
		public DateTime CreationDate { get; set; }
		[BsonElement(UserFieldNames.Email)]
		public String Email { get; set; }
		[BsonElement(UserFieldNames.FailedPasswordAnswerAttemptCount)]
		public Int32 FailedPasswordAnswerAttemptCount { get; set; }
		[BsonElement(UserFieldNames.FailedPasswordAnswerAttemptWindowStart)]
		public DateTime FailedPasswordAnswerAttemptWindowStart { get; set; }
		[BsonElement(UserFieldNames.FailedPasswordAttemptCount)]
		public Int32 FailedPasswordAttemptCount { get; set; }
		[BsonElement(UserFieldNames.FailedPasswordAttemptWindowStart)]
		public DateTime FailedPasswordAttemptWindowStart { get; set; }
		[BsonElement(UserFieldNames.IsApproved)]
		public Boolean IsApproved { get; set; }
		[BsonElement(UserFieldNames.IsAnonymous)]
		public Boolean IsAnonymous { get; set; }
		[BsonElement(UserFieldNames.IsLockedOut)]
		public Boolean IsLockedOut { get; set; }
		[BsonElement(UserFieldNames.LastActivityDate)]
		public DateTime LastActivityDate { get; set; }
		[BsonElement(UserFieldNames.LastLockoutDate)]
		public DateTime LastLockoutDate { get; set; }
		[BsonElement(UserFieldNames.LastLoginDate)]
		public DateTime LastLoginDate { get; set; }
		[BsonElement(UserFieldNames.LastPasswordChangedDate)]
		public DateTime LastPasswordChangedDate { get; set; }
		[BsonElement(UserFieldNames.Password)]
		public String Password { get; set; }
		[BsonElement(UserFieldNames.PasswordAnswer)]
		public String PasswordAnswer { get; set; }
		[BsonElement(UserFieldNames.PasswordQuestion)]
		public String PasswordQuestion { get; set; }
		[BsonElement(UserFieldNames.Salt)]
		public String Salt { get; set; }
		[BsonElement(UserFieldNames.Username)]
		public String Username { get; set; }
		[BsonElement(UserFieldNames.ApplicationName)]
		public String ApplicationName { get; set; }
		[BsonElement(UserFieldNames.UpperUsername)]
		public String UpperUsername { get; set; }
		[BsonElement(UserFieldNames.Comment)]
		public String Comment { get; set; }

		[BsonElement(UserFieldNames.Roles)]
		public IList<String> Roles { get; set; }

		[BsonIgnoreIfNull]
		//[BsonElement(UserFieldNames.Profile)]
		public UserProfile Profile { get; set; }
	}

	internal static class UserFieldNames {
		public const String Id = "_id";
		public const String CreationDate = "creation";
		public const String Email = "email";
		public const String FailedPasswordAnswerAttemptCount = "fpaac";
		public const String FailedPasswordAnswerAttemptWindowStart = "fpaaws";
		public const String FailedPasswordAttemptCount = "fpac";
		public const String FailedPasswordAttemptWindowStart = "fpaws";
		public const String IsApproved = "approved";
		public const String IsLockedOut = "locked";
		public const String LastActivityDate = "lastactivity";
		public const String LastLockoutDate = "lastlockout";
		public const String LastLoginDate = "lastlogin";
		public const String LastPasswordChangedDate = "lastpwchange";
		public const String Password = "password";
		public const String PasswordAnswer = "answer";
		public const String PasswordQuestion = "question";
		public const String Salt = "salt";
		public const String Username = "username";
		public const String ApplicationName = "applicationname";
		public const String UpperUsername = "uusername";
		public const String Comment = "comment";
		public const String Roles = "roles";
		public const String IsAnonymous = "anonymous";
		public const String Profile = "profile";
	}
}